#!/usr/bin/env tclsh
set l1 [list 1 2 {3 4}]
puts "l1 = $l1"

# concat连接
set l1 [list yhp i love]
set l2 [list you]
set l3 [concat $l1 $l2 $l2]
puts "l1 = $l1"
puts "l2 = $l2"
puts "l3 = $l3"

# lindex访问
set i 0
# list的长度
set len [llength $l1]
puts "len=$len" 

#遍历l1
for {set i 0} {$i < $len} {incr i} {
    puts "l1\[$i\] = [lindex $l1 $i]"
}

## linsert list index value1 value2 命令
set l1 [list mdx i you]
set l2 [list love]
puts "l1 = $l1"
set l3 [linsert $l1 2 $l2]
puts "l3 = $l3"

## lreplace list first last value1 value2
puts +++++++++++
set l1 [list mdx i you]
set l2 [list love]
set l3 [lreplace $l1 0 1 $l2];#替代
puts "l3 = $l3"
set l3 [lreplace $l1 0 1 ];#删除
puts "l3 = $l3"

#截取lrange
puts +++++++++++
set l1 [list mdx i you]
set l2 [list love]
set l3 [lrange $l1 1 2]
puts "l3 = $l3"

set l3 [lappend l3 1 3 kk]
puts "l3 = $l3"